#set(seoTitle="发布文章")
#@layout()
#define main()
<!-- 内容区域 -->
<div class="aw-container-wrap">
    <div class="container aw-publish aw-publish-article">
        <div class="row">
            <div class="aw-content-wrap clearfix">
                <div class="col-sm-12 col-md-9 aw-main-content">
                    <!-- tab 切换 -->
                    <ul class="nav nav-tabs aw-nav-tabs active">
                        <li class="active">
                            <a href="javascript:volid(0);">文章</a>
                        </li>
                        <h2><i class="icon icon-ask"></i>发起</h2>
                    </ul>
                    <!-- end tab 切换 -->
                    <form id="myArticleForm" action="/my/article/save" method="post" name="write_post">
                        <div class="aw-mod aw-mod-publish">
                            <div class="mod-body">
                                <h3>文章标题</h3>
                                <!-- 文章标题 -->
                                <div class="aw-publish-title">
                                    <input type="text" name="article.title" value="" class="form-control" placeholder="请输入标题">
                                    <div class="dropdown">
                                        <select name="article.type_id" class="dropdown-toggle" id="article.type_id">
                                            <option value="">- 请选择分类 -</option>
                                            #for(comments : commentsList)
                                            <option value="#(comments.tid)">#(comments.name)</option>
                                            #end
                                        </select>
                                    </div>
                                </div>
                                <h3>是否使用积分下载
                                    <span style="margin-left: 5px">
                                        <label class="radio-inline">
                                            <input type="radio" name="article.is_pay" value="0" checked>否
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="article.is_pay" value="1">是
                                        </label>
                                    </span>
                                </h3>

                                <div class="aw-publish-title">
                                    <input type="text" name="article.download" value="" class="form-control" placeholder="请输入下载链接"><br/>
                                    <input type="text" name="article.password" value="" class="form-control" placeholder="请输入下载密码">
                                    <div class="dropdown">
                                        <select name="article.points" class="dropdown-toggle" id="article.points">
                                            <option value="">- 请选择积分 -</option>
                                            <option value="0">0个积分</option>
                                            <option value="1">1个积分</option>
                                            <option value="2">2个积分</option>
                                            <option value="3">3个积分</option>
                                            <option value="4">4个积分</option>
                                            <option value="5">5个积分</option>
                                            <option value="6">6个积分</option>
                                            <option value="7">7个积分</option>
                                            <option value="8">8个积分</option>
                                            <option value="9">9个积分</option>
                                            <option value="10">10个积分</option>
                                        </select>
                                    </div>
                                </div>


                                <!-- end 文章标题 -->
                                <h3>文章内容:</h3>
                                <div class="content-box" style="line-height: 20px;">
                                    <script id="container" name="article.content" style="line-height: 20px;"  type="text/plain" ></script>
                                </div>
                            </div>
                            <div class="mod-footer clearfix">
                                <a href="/detail/1" target="_blank">[积分规则]</a>
                                <span class="aw-anonymity"></span>
                                <input class="btn btn-large btn-success btn-publish-submit" type="submit"
                                       value="确认&nbsp;发起"/>
                            </div>
                        </div>
                    </form>
                </div>
                <!-- 侧边栏 -->
                <div class="col-sm-12 col-md-3 aw-side-bar hidden-xs">
                    <!-- 文章发起指南 -->
                    <div class="aw-mod publish-help">
                        <div class="mod-head">
                            <h3>文章发起指南</h3>
                        </div>
                        <div class="mod-body">
                            <p>
                                <b>• 文章标题:</b>请用准确的语言描述您发布的文章思想
                            </p>
                            <p>
                                <b>• 文章补充:</b>详细补充您的文章内容, 并提供一些相关的素材以供参与者更多的了解您所要文章的主题思想
                            </p>
                            <p>
                                <b>• 注意事项:</b>
                                文章不能内容相同，且不能言论时政，亦不能发黄色内容，违反会被封号，请珍惜账号
                            </p>
                            <p>
                                <b>• 问题反馈:</b>
                                如果您希望他人花一分钟来解答您的问题，还请您耐心花10分钟来完善您的提问。如：获取日志，代码块，运行环境等
                            </p>
                        </div>
                    </div>
                    <!-- end 文章发起指南 -->
                </div>
                <!-- end 侧边栏 -->
            </div>
        </div>
    </div>
</div>
<!-- 内容区域end -->
#end

#define js()
<script type="text/javascript" src="/static/jquery_form/jquery.form.min.js"></script>
<script type="text/javascript" src="/static/layer/layer/layer.js"></script>

#include("/_view/my/common/_my_space_article_form_js.html")
<script type="text/javascript">
    // 上传时在 url 中用问号挂参的方式添加额外的参数 uploadType，用于分类管理图片
    ue.ready(function () {
        ue.execCommand('serverparam', {
            'uploadType': 'article'
        });
    });

    // 也用 ajax 提交比较好，这样有利于在出异常的时候信息不会丢失
    $(document).ready(function () {
        $("#myArticleForm").ajaxForm({
            dataType: "json"
            , beforeSubmit: function (formData, jqForm, options) {
                ue.sync();  // 同步一下 ueditor 中的数据到表单域
            }
            , success: function (ret) {
                if (ret.state == "ok") {
                    location.href = "/my/article/list";
                } else {
                    showErrorMsg(ret.msg);
                }
            }
            , error: function (ret) {
                alert(ret);
            }
            , complete: function (ret) {
            }       // 无论是 success 还是 error，最终都会被回调
        });
    });

    function showErrorMsg(msg) {
        layer.msg(msg, {
                shift: 6
                , shade: 0.4
                , time: 0
                , offset: "140px"
                , closeBtn: 1
                , shadeClose: true
                , maxWidth: "1000"
            }, function () {
            }
        );
    }

</script>
#end